/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tk.eigh.ksvg.renderer.text;


import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import ksvg.text.TextSpan;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
import org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils;
import tk.eigh.ksvg.SVG;
import tk.eigh.ksvg.renderer.SVGRenderer;
import tk.eigh.ksvg.renderer.SVGRendererUtils;

/**
 *
 * @author nt
 */
@JSFRenderer(renderKitId="SVG",type="SVGTextSpanRenderer",family="text.TextSpan")
public class SVGTextSpanRenderer extends SVGTextContentRenderer{

    protected final static String TAG_NAME = "tspan";

    @Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        super.encodeBegin(context, component);

        ResponseWriter writer = context.getResponseWriter();
        TextSpan textspan = (TextSpan) component;
        writer.startElement(TAG_NAME, component);
        renderCommonAttributes(writer,component,context);
        SVGRendererUtils.renderImplementedAttributes(component, writer);
        HtmlRendererUtils.renderHTMLAttributes(writer, component, SVG.TSPAN_ELEMENT_PROPERTIES);
        writer.writeText(textspan.getValue(),"value");
    }

    @Override
    public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
        super.encodeEnd(context, component);
        context.getResponseWriter().endElement(TAG_NAME);
    }

}
